﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_ModifyPassword : System.Web.UI.Page
{
	private int nColumnID;
	private int nLoginUserID;
	private ColumnComponent clsColumnComp = new ColumnComponent();
	private UserComponent clsUserComp = new UserComponent();

	protected void Page_Load(object sender, EventArgs e)
	{
		nColumnID = Convert.ToInt32(Request.QueryString["id"]);
		nLoginUserID = Convert.ToInt32(Session["LoginUserID"]);

		LabColumnName.Text = clsColumnComp.GetOneByID(nColumnID).Name;

		////////////////////////////////////////////////////////////////////////////////
		// 控件事件添加
		BtnModify.Click += new EventHandler(BtnModify_OnClick);		// 修改按钮
		////////////////////////////////////////////////////////////////////////////////
	}

	protected void BtnModify_OnClick(object sender, EventArgs e)
	{
		User clsLoginUser;

		clsLoginUser = clsUserComp.GetOneByID(nLoginUserID);

		if (TxtNewPassword.Text.Trim() == TxtConfirmPassword.Text.Trim())
		{
			if (clsLoginUser.Password == TxtOldPassword.Text.Trim())
			{
				clsLoginUser.Password = TxtNewPassword.Text;
				if (clsUserComp.Modify(clsLoginUser))
				{
					ShowMessageAlert.ShowMessage("修改成功！");
				}
			}
			else
			{
				ShowMessageAlert.ShowMessage("旧密码错误！");
			}
		}
		else
		{
			ShowMessageAlert.ShowMessage("新密码和确认密码不一致！");
		}
	}
}
